package me.trytofeel.controller;

import lombok.Data;
import me.trytofeel.bean.Video;
import me.trytofeel.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

import java.util.List;

@Data
@Controller // 是通过注解，来表明身份要被扫描成组件，bean被IOC容器接管
public class VideoController {
    @Autowired
    private VideoService videoService;

    public List<Video> selectAllVideos() {
        return videoService.selectAllVideos();
    }

    public Video selectVideoById(int id) {
        return videoService.selectVideoById(id);
    }

    public String deleteVideoById(int id) {
        return videoService.deleteVideoById(id) ? "删除成功" : "删除失败";
    }

    public String insertOneVideo(Video video) {
        return videoService.insertOneVideo(video) ? "添加成功" : "添加失败";
    }

    public String updateOneVideo(Video video) {
        return videoService.updateOneVideo(video) ? "更新成功" : "更新失败";
    }
}
